<template>
	<view class="status_bar">
		<!-- 这里是状态栏 -->
	</view>
	<view class="page-nav-bar">
		<view class="page-nav-bar-left">
			<view class="avatar">
				
			</view>
			<text class="user-name">联系人</text>
		</view>
		<view class="page-nav-bar-right">
			<uni-icons type="personadd-filled" :size="30" @click="toAppend"></uni-icons>
		</view>
	</view>
	<view class="page-search">
		<uni-search-bar radius="5" placeholder="搜索..." cancelButton="none"/>
	</view>
	<view class="page-search">
		<uni-list>
			<uni-list-item clickable link="navigateTo" title="新的朋友" to="/pages/friendNews/friendNews"></uni-list-item>
			<uni-list-item clickable :show-arrow="false" :show-extra-icon="true" :extra-icon="{color: '#565656',size: '30',type: 'person'}" v-for="item of list" :key="item._id" :title="item.name" @click="toVisitor(item)"></uni-list-item>
		</uni-list>
	</view>
</template>

<script setup lang="ts">
	import { ref, onMounted } from 'vue';
	import request from '../../common/request';
	const userInfo = uni.getStorageSync('userInfo')
	console.log(userInfo)
	
	const list = ref([])
	onMounted(() => {
		getContactPerson()
	})
	
	async function getContactPerson() {
		const { code, data } = await request.post('/contactList')
		if (code) {
			list.value = data
			console.log('/contactList', list.value)
		}
	}
	
	const toAppend = () => {
		uni.navigateTo({
			url: '/pages/append/append',
			animationType: 'pop-in',
			animationDuration: 200
		})
	}
	
	const toVisitor = (visitor: any) => {
		console.log(visitor)
		uni.setStorageSync('visitor', visitor)
		uni.navigateTo({
			url: '/pages/visitor/visitor',
			animationType: 'pop-in',
			animationDuration: 200
		})
	}
</script>

<style>
</style>
